package regex;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javafx.util.Pair;
import utils.StringUtils;

public class AtUtils {

    private static final String AT_START = "@";
    private static final char AT_END = 0x07;

    public static List<Pair<Integer, Integer>> indexOfAt(String text) {
        List<Pair<Integer, Integer>> list = new ArrayList<>();
        if (StringUtils.isEmpty(text)) {
            return list;
        }

        int start = 0, end = 0;
        for (int i = 0; i < text.length(); i++) {
            if (text.charAt(i) == AT_START.charAt(0)) {
                start = i;
            } else if (text.charAt(i) == AT_END) {
                end = i;
            }

            if (end > start && start > 0) {
                list.add(new Pair<>(start, end));
            }
        }

        return list;
    }

}
